package com.xyy.saas.payment.service.impl;

import com.xyy.saas.payment.dao.mapper.ApplyBankcardModifyMapper;
import com.xyy.saas.payment.dao.model.ApplyBankcardModify;
import com.xyy.saas.payment.service.ApplyBankcardModifyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class ApplyBankcardModifyServiceImpl implements ApplyBankcardModifyService {
    @Resource
    private ApplyBankcardModifyMapper applyBankcardModifyMapper;

    /**
     * 插入
     *
     * @param record
     */
    @Override
    public boolean insertSelective(ApplyBankcardModify record) {
        return applyBankcardModifyMapper.insertSelective(record) > 0;
    }

    /**
     * 更新
     *
     * @param record
     */
    @Override
    public boolean updateByPrimary(ApplyBankcardModify record) {
        return applyBankcardModifyMapper.updateByPrimary(record) > 0;
    }

    /**
     * 查询是否绑定成功过卡
     */
    @Override
    public Integer binded(String accountId) {
        return applyBankcardModifyMapper.binded(accountId);
    }

    /**
     * 根据商户ID查询最近一条记录
     *
     * @param accountId
     */
    @Override
    public ApplyBankcardModify queryApplyInfoByAccountId(String accountId, String source) {
        return applyBankcardModifyMapper.queryApplyInfoByAccountId(accountId, source);
    }

    /**
     * 根据商户ID查询所有申请记录
     *
     * @param accountId
     * @param source
     */
    @Override
    public List<ApplyBankcardModify> queryApplyInfoListByAccountId(String accountId, String source) {
        return applyBankcardModifyMapper.queryApplyInfoListByAccountId(accountId, source);
    }

    /**
     * 根据申请单号查询
     *
     * @param applyNo
     */
    @Override
    public ApplyBankcardModify queryApplyInfoByApplyNo(String applyNo) {
        return applyBankcardModifyMapper.queryApplyInfoByApplyNo(applyNo);
    }

    /**
     * 根据状态查询
     */
    @Override
    public List<ApplyBankcardModify> queryApplyInfoStatus(Integer status) {
        return applyBankcardModifyMapper.queryApplyInfoStatus(status);
    }
}